package com.powernode.ssm.result;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class R<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> R<T> OK(){
        return R.<T>builder().code(CodeEnum.OK.getCode()).msg(CodeEnum.OK.getMsg()).build();
    }

    public static <T> R<T> OK(T data){
        return R.<T>builder().code(CodeEnum.OK.getCode()).msg(CodeEnum.OK.getMsg()).data(data).build();
    }

    public static <T> R<T> Fail(){
        return R.<T>builder().code(CodeEnum.FAIL.getCode()).msg(CodeEnum.FAIL.getMsg()).build();
    }

    public static <T> R<T> Fail(CodeEnum codeEnum){
        return R.<T>builder().code(codeEnum.getCode()).msg(codeEnum.getMsg()).build();
    }


}
